local lingse = fk.CreateSkill {
  name = "hanqing__lingse",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["hanqing__lingse"] = "令色",
  [":hanqing__lingse"] = "锁定技，若弃牌堆里没有【八卦阵】，你视为装备之。",
}

local spec = {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(lingse.name) and
      Exppattern:Parse(data.pattern):matchExp("jink") and
      not table.find(player.room.discard_pile, function (id)
        return Fk:getCardById(id).trueName == "eight_diagram"
      end) and
      Fk.skills["#eight_diagram_skill"] ~= nil and Fk.skills["#eight_diagram_skill"]:isEffectable(player)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = lingse.name,
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/standard_cards/audio/card/eight_diagram")
    room:setEmotion(player, "./packages/standard_cards/image/anim/eight_diagram")
    local skill = Fk.skills["#eight_diagram_skill"]
    skill:use(event, target, player, data)
  end,
}

lingse:addEffect(fk.AskForCardUse, spec)
lingse:addEffect(fk.AskForCardResponse, spec)

return lingse
